from abaqusGui import *
from abaqusConstants import ALL
import osutils, os


###########################################################################
# Class definition
###########################################################################

class TCNTsimu_ver2024_plugin(AFXForm):

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def __init__(self, owner):
        
        # Construct the base class.
        #
        AFXForm.__init__(self, owner)
        self.radioButtonGroups = {}

        self.cmd = AFXGuiCommand(mode=self, method='creatJob',
            objectName='TCNTanalysis', registerQuery=False)
        pickedDefault = ''
        self.model_nameKw = AFXStringKeyword(self.cmd, 'model_name', True, '')
        self.job_nameKw = AFXStringKeyword(self.cmd, 'job_name', True, '')
        self.tube_lenKw = AFXFloatKeyword(self.cmd, 'tube_len', True, 40)
        self.degreeKw = AFXFloatKeyword(self.cmd, 'degree', True, 0)
        self.T1_DKw = AFXFloatKeyword(self.cmd, 'T1_D', True, 130)
        self.T1_tKw = AFXFloatKeyword(self.cmd, 'T1_t', True, 5)
        self.T2_DKw = AFXFloatKeyword(self.cmd, 'T2_D', True, 60)
        self.T2_tKw = AFXFloatKeyword(self.cmd, 'T2_t', True, 3)
        self.T3_tKw = AFXFloatKeyword(self.cmd, 'T3_t', True, 3)
        self.rect_bKw = AFXFloatKeyword(self.cmd, 'rect_b', True, 200)
        self.rect_hKw = AFXFloatKeyword(self.cmd, 'rect_h', True, 40)

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def getFirstDialog(self):

        import tCNTsimu_ver2024DB
        return tCNTsimu_ver2024DB.TCNTsimu_ver2024DB(self)

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def doCustomChecks(self):

        # Try to set the appropriate radio button on. If the user did
        # not specify any buttons to be on, do nothing.
        #
        for kw1,kw2,d in self.radioButtonGroups.values():
            try:
                value = d[ kw1.getValue() ]
                kw2.setValue(value)
            except:
                pass
        return True

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def okToCancel(self):

        # No need to close the dialog when a file operation (such
        # as New or Open) or model change is executed.
        #
        return False

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Register the plug-in
#
thisPath = os.path.abspath(__file__)
thisDir = os.path.dirname(thisPath)

toolset = getAFXApp().getAFXMainWindow().getPluginToolset()
toolset.registerGuiMenuButton(
    buttonText='TCNTsimu', 
    object=TCNTsimu_ver2024_plugin(toolset),
    messageId=AFXMode.ID_ACTIVATE,
    icon=None,
    kernelInitString='import TCNTanalysis',
    applicableModules=ALL,
    version='N/A',
    author='N/A',
    description='N/A',
    helpUrl='N/A'
)
